package com.lry.dao;

import java.util.List;

import com.lry.bean.Role;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 
 *
 * @author 李瑞益
 * @date 2019/8/20
 */
public interface RoleMapper {

    @Select({
            "select user_id,role_id,role_name where user_id = #{userId,jdbcType=VARCHAR}"
    })
    List<Role> listRoleByUserId(Long userId);

//    @Insert({
//            "<script>",
//            "insert into role_user(role_id,user_id) values",
//            "<foreach collection='roles' item='role' separator=',' open='(' close=')'>",
//            "#{role,jdbcType=INTEGER},#{userId,jdbcType=INTEGER}",
//            "</foreach>",
//            "<script>"
//    })
    @InsertProvider(type = RoleSqlProvider.class,method = "addRoles")
    int addRoles(@Param("roles")int[] roles,@Param("userId")Long userId);
}
